package com.qifan.energy.util;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.Toast;

import com.qifan.energy.global.MyApplication;
import com.qifan.energy.R;
import com.muddzdev.styleabletoast.StyleableToast;

/* 吐司工具类（静态方法） */
public class ToastUtils {

    public static void showShort(String message){
        showShort(MyApplication.getContext(),message);
    }

    public static void showShort(Context context,String message){
        new StyleableToast.Builder(context)
                .text(message)
                .stroke(2, Color.BLACK)
                .backgroundColor(Color.BLACK)
                .solidBackground()
                .textColor(Color.WHITE)
                .textBold()
                .cornerRadius(12)
                .textSize(18)
                .gravity(Gravity.CENTER)
                .length(Toast.LENGTH_SHORT)
                .show();
                /*.font(R.font.dosis)*/
                /*.iconStart(getIcon())
                .iconEnd(getIcon())*/
    }

    public static void showLong(String message){
        showLong(MyApplication.getContext(),message);
    }

    public static void showLong(Context context,String message){
        new StyleableToast.Builder(context)
                .text(message)
                .stroke(2, Color.BLACK)
                .backgroundColor(Color.BLACK)
                .solidBackground()
                .textColor(Color.WHITE)
                .textBold()
                .cornerRadius(12)
                .textSize(18)
                .gravity(Gravity.CENTER)
                .length(Toast.LENGTH_LONG)
                .show();
        /*.font(R.font.dosis)*/
                /*.iconStart(getIcon())
                .iconEnd(getIcon())*/
    }

    public static void showLong2(String message){
        StyleableToast.makeText(MyApplication.getContext(), message, R.style.mytoast).show();
    }

    public static void showLong2(Context context,String message){
        StyleableToast.makeText(context, message, R.style.mytoast).show();
    }

    public static int getIcon() {
        if (android.os.Build.VERSION.SDK_INT >= 27) {
            return R.drawable.ic_autorenew_black_24dp;
        } else {
            return R.drawable.ic_autorenew_white_24dp;
        }
    }
}
